using UnityEngine;

public class CreateObjectPooling : MonoBehaviour
{
	public GameObject pref;

	public GameObject[] objectsPool;

	public int maxnumOb;

	private void Awake()
	{
		Init();
	}

	public void Init()
	{
		objectsPool = new GameObject[maxnumOb];
		for (int i = 0; i < maxnumOb; i++)
		{
			objectsPool[i] = UnityEngine.Object.Instantiate(pref);
			objectsPool[i].name = pref.name + i;
			objectsPool[i].SetActive(value: false);
			objectsPool[i].transform.parent = base.transform;
		}
	}

	public void _ChooseEffect(Vector3 pos)
	{
		int num = 0;
		while (true)
		{
			if (num < objectsPool.Length)
			{
				if (objectsPool[num] != null && !objectsPool[num].activeInHierarchy)
				{
					break;
				}
				num++;
				continue;
			}
			return;
		}
		objectsPool[num].transform.position = pos;
		objectsPool[num].transform.parent = null;
		objectsPool[num].SetActive(value: true);
	}
}
